from selenium.webdriver import Chrome
import time
from selenium.webdriver.common import by
from selenium.webdriver.common import keys

# openwrt登录账号密码
user = "root"  # 默认账号已填写
pwd = "password"


# 创建一个webDriver实例
web = Chrome()
# 窗口最大化
web.maximize_window()
# 访问目标网站
url = 'http://192.168.1.1'
web.get(url)
time.sleep(1)  # 加载页面

# 查找输入框，点击
el = web.find_element(by.By.XPATH, '//*[@id="maincontent"]/div/form/div[1]/fieldset/fieldset/div[2]/div/input')
el.click()
# 输入密码
el.send_keys(pwd, keys.Keys.ENTER)
time.sleep(1)  # 加载页面
# 网络-接口
inter_url = url + "/cgi-bin/luci/admin/network/network"
web.get(inter_url)
time.sleep(1)  # 加载页面
# 重启接口
# el = web.find_element(by.By.XPATH, '//*[@id="cbi-network"]/div/fieldset/table/tbody/tr[4]/td[3]/input[1]')
# el.click()


# 设置睡眠时间
time.sleep(10000)
